package cn.credit.loan.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import cn.credit.loan.entity.Purpose;
import cn.credit.loan.service.purpose.PurposeService;

@Controller
public class PurposeController {
	
	private static Logger logger=Logger.getLogger(PurposeController.class);
	
	@Autowired
	private PurposeService purposeService;
	
	/**
	 * 查看贷款用途
	 * @return
	 */
	@RequestMapping(value="/purList")
	@ResponseBody
	public Object purList(){
		 List<Purpose> purposelist=null;
		 try {
			 purposelist=purposeService.getPurpose();
		} catch (Exception e) {
			e.printStackTrace();
		}   
		return purposelist;
	}
	
	/**
	 * 添加贷款用途类型
	 * @param purpose
	 * @return
	 */
	@RequestMapping(value="/addpurpose")
	@ResponseBody
	public Object addPur(Purpose purpose){
		logger.info("####-------->> 进入添加贷款用途类型");
		Map<String , Object> result=new HashMap<String,Object>();
		try {
			result.put("pose", purposeService.addPurpose(purpose));
		} catch (Exception e) {
			logger.info("####-------->> 出现异常");
			e.printStackTrace();
		}
		return result;
	}
}
